home *** CD-ROM | disk | FTP | other *** search
- ;void format_right(strg,distance,color);
- ; unsigned char *strg,color;
- ; unsigned short distance;
-
- EXTRN _memory_model:byte
- EXTRN _video_buffer:word
- EXTRN _video_page:byte
- EXTRN _snow_protect:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _format_right
- _format_right proc near
- cld ;set direction flag
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: mov bh,_video_page ;get BIOS page
- mov ax,_video_buffer ;fetch _video_buffer
- mov es,ax ;move to ES
- push ds ;save DS
- mov ah,3 ;BIOS call for curs pos
- int 10h ;DH-DL cursor row-col
- mov ax,160 ;bytes per row
- mul dh ;times rows
- sub cx,cx ;clear CX
- mov cl,dl ;cols to CX
- shl cl,1 ;double for attributes
- add ax,cx ;add to row offset
- mov di,ax ;place offset in DI
- mov bl,_snow_protect ;fetch _snow_protect
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- lds si,dword ptr[bp+4] ;DS:SI pts to Strg
- inc bp ;add 2 to BP since dword ptr
- inc bp ;
- jmp short L00 ;
- L0: mov si,[bp+4] ;near case
- L00: mov byte ptr[bp+4],bl ;keep _snow_protect
- cmp byte ptr[si],0 ;test for null string
- je L5 ;
- push dx ;save cursor values
- push bx ;save video page
- mov bh,[bp+8] ;attribute to BH
- sub cx,cx ;count string length in CX
- L000: inc si ;move SI to end of string
- inc cx ;inc string length counter
- cmp byte ptr[si],0 ;test for end of string
- jne L000 ;loop
- dec si ;pull back pointer
- L1: mov bl,[si] ;get a char
- cmp byte ptr[bp+4],0 ;protect against snow?
- je L4 ;jump if not
- mov dx,3dah ;status byte address
- L2: in al,dx ;get status byte
- test al,1 ;test bit
- jnz L2 ;loop till 0
- cli ;disable interrupts
- L3: in al,dx ;get status byte
- test al,1 ;test bit
- jz L3 ;loop till 1
- L4: mov ax,bx ;get char-attribute
- stosw ;write it
- sub di,4 ;pull back scrn ptr
- dec si ;dec Strg ptr
- loop L1 ;go do next char
- sti ;reenable interrupts
- pop bx ;video page back to BH
- pop dx ;restore cursor values
- L5: mov cx,[bp+6] ;get new cursor offset
- test cx,8000h ;negative?
- jz L6 ;jump if not
- neg CX ;make positive
- add dh,cl ;add to row offset
- cmp dh,24 ;bottom of screen?
- jb L7 ;jump if not
- mov dh,24 ;else edge of screen
- jmp short L7 ;to set cursor
- L6: add dl,cl ;add to col offset
- cmp dl,79 ;off screen?
- jb L7 ;jump if not
- mov dl,79 ;else edge of screen
- L7: mov ah,2 ;BIOS func to set curs
- int 10h ;set new cursor pos
- pop ds ;
- pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _format_right endp
- _TEXT ENDS
- END